package com.cool.algorithm;

import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class OrderPreservationExample {
    public static void main(String[] args) {
        // 使用 HashMap
        Map<String, String> hashMap = new HashMap<>();
        hashMap.put("one", "1");
        hashMap.put("two", "2");
        hashMap.put("three", "3");
        hashMap.put("four", "4");
        hashMap.put("five", "5");
        hashMap.put("six", "6");
        hashMap.put("seven", "7");
        hashMap.put("eight", "8");

        hashMap.forEach((key, value) -> System.out.println(key + ": " + value));


        Map<String, String> linkedHashMap = new LinkedHashMap();
        linkedHashMap = hashMap;
        System.out.println("=====================");
        linkedHashMap.forEach((key, value) -> System.out.println(key + ": " + value));

    }
}
